package table;

import mips.Reg;

import java.util.ArrayList;

public class Grf {
    public static Reg zero = new Reg("zero");
    public static Reg at = new Reg("at");
    public static Reg v0 = new Reg("v0");
    public static Reg v1 = new Reg("v1");
    public static Reg a0 = new Reg("a0");
    public static Reg a1 = new Reg("a1");
    public static Reg a2 = new Reg("a2");
    public static Reg a3 = new Reg("a3");
    public static Reg t0 = new Reg("t0");
    public static Reg t1 = new Reg("t1");
    public static Reg t2 = new Reg("t2");
    public static Reg t3 = new Reg("t3");
    public static Reg t4 = new Reg("t4");
    public static Reg t5 = new Reg("t5");
    public static Reg t6 = new Reg("t6");
    public static Reg t7 = new Reg("t7");
    public static Reg s0 = new Reg("s0");
    public static Reg s1 = new Reg("s1");
    public static Reg s2 = new Reg("s2");
    public static Reg s3 = new Reg("s3");
    public static Reg s4 = new Reg("s4");
    public static Reg s5 = new Reg("s5");
    public static Reg s6 = new Reg("s6");
    public static Reg s7 = new Reg("s7");
    public static Reg t8 = new Reg("t8");
    public static Reg t9 = new Reg("t9");
    public static Reg k0 = new Reg("k0");
    public static Reg k1 = new Reg("k1");
    public static Reg gp = new Reg("gp");
    public static Reg sp = new Reg("sp");
    public static Reg fp = new Reg("fp");
    public static Reg ra = new Reg("ra");

    public static ArrayList<Reg> regs_temp = new ArrayList<>();
    public static ArrayList<Reg> regs_save = new ArrayList<>();
    public static ArrayList<Reg> regs_attr = new ArrayList<>();
    public static ArrayList<Reg> regs_verb = new ArrayList<>();

    public static void Init() {
        regs_temp.add(t0);
        regs_temp.add(t1);
        regs_temp.add(t2);
        regs_temp.add(t3);
        regs_temp.add(t4);
        regs_temp.add(t5);
        regs_temp.add(t6);
        regs_temp.add(t7);
        regs_temp.add(t8);
        regs_temp.add(t9);

        regs_save.add(s0);
        regs_save.add(s1);
        regs_save.add(s2);
        regs_save.add(s3);
        regs_save.add(s4);
        regs_save.add(s5);
        regs_save.add(s6);
        regs_save.add(s7);

        regs_attr.add(a0);
        regs_attr.add(a1);
        regs_attr.add(a2);
        regs_attr.add(a3);

        regs_verb.add(v0);
        regs_verb.add(v1);
    }

    public static void releaseAll() {
        for (Reg reg: regs_attr) {
            reg.release();
        }
    }

}
